using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using System.Text;
using ECommerce.DAL;


namespace Entity
{
	/// <summary>
	/// This object represents the Private Fields of TblUserProfile.
	/// </summary>
	
	[System.ComponentModel.DataObject]
    public class TblUserProfile : DatabaseUtility
    {
		#region TblUserProfile Private Fields


		Int32 _userProfileId;
		String _firstName = String.Empty;
		String _lastName = String.Empty;
		DateTime _dateOfBirth;
		String _emailAddress = String.Empty;
		String _userGender = String.Empty;
		String _userTelephoneNumber = String.Empty;
		String _userFaxNumber = String.Empty;
		String _companyName = String.Empty;
		String _companyTelephoneNumber = String.Empty;
		String _companyFaxNumber = String.Empty;
		String _billingFirstName = String.Empty;
		String _billingLastName = String.Empty;
		String _billingAddressLine1 = String.Empty;
		String _billingAddressLine2 = String.Empty;
		String _billingCity = String.Empty;
		String _billingAddressState = String.Empty;
		String _billingAddressCountry = String.Empty;
		String _billingZipCode = String.Empty;
		String _billingTelephoneNumber = String.Empty;
		String _billingEmailAddress = String.Empty;
		String _shippingFirstName = String.Empty;
		String _shippingLastName = String.Empty;
		String _shippingAddressLine1 = String.Empty;
		String _shippingAddressLine2 = String.Empty;
		String _shippingCity = String.Empty;
		String _shippingAddressState = String.Empty;
		String _shippingAddressCountry = String.Empty;
		String _shippingZipCode = String.Empty;
		String _shippingTelephoneNumber = String.Empty;
		String _shippingEmailAddress = String.Empty;
		Boolean _isActive;
		Boolean _isDeleted;
		DateTime _createDate;
		Int32 _userId;
		String _adminComment = String.Empty;
		
		#endregion
		#region TblUserProfile Constractor
		/// <summary>
        /// Creates an empty object of TblUserProfile. 
        /// This is mainly used to create a new instance of TblUserProfile to add a new TblUserProfile.
        /// </summary>
		public TblUserProfile(){}
		
				
		/// <summary>
        /// Used to retrieve employee information from database, 
        /// which is also used by Update method to save information of an existing TblUserProfile.
        /// </summary>
		public TblUserProfile
		(
			Int32 userProfileId,
			String firstName,
			String lastName,
			DateTime dateOfBirth,
			String emailAddress,
			String userGender,
			String userTelephoneNumber,
			String userFaxNumber,
			String companyName,
			String companyTelephoneNumber,
			String companyFaxNumber,
			String billingFirstName,
			String billingLastName,
			String billingAddressLine1,
			String billingAddressLine2,
			String billingCity,
			String billingAddressState,
			String billingAddressCountry,
			String billingZipCode,
			String billingTelephoneNumber,
			String billingEmailAddress,
			String shippingFirstName,
			String shippingLastName,
			String shippingAddressLine1,
			String shippingAddressLine2,
			String shippingCity,
			String shippingAddressState,
			String shippingAddressCountry,
			String shippingZipCode,
			String shippingTelephoneNumber,
			String shippingEmailAddress,
			Boolean isActive,
			Boolean isDeleted,
			DateTime createDate,
			Int32 userId,
			String adminComment
		)
		{
			_userProfileId = userProfileId;	
			_firstName = firstName;	
			_lastName = lastName;	
			_dateOfBirth = dateOfBirth;	
			_emailAddress = emailAddress;	
			_userGender = userGender;	
			_userTelephoneNumber = userTelephoneNumber;	
			_userFaxNumber = userFaxNumber;	
			_companyName = companyName;	
			_companyTelephoneNumber = companyTelephoneNumber;	
			_companyFaxNumber = companyFaxNumber;	
			_billingFirstName = billingFirstName;	
			_billingLastName = billingLastName;	
			_billingAddressLine1 = billingAddressLine1;	
			_billingAddressLine2 = billingAddressLine2;	
			_billingCity = billingCity;	
			_billingAddressState = billingAddressState;	
			_billingAddressCountry = billingAddressCountry;	
			_billingZipCode = billingZipCode;	
			_billingTelephoneNumber = billingTelephoneNumber;	
			_billingEmailAddress = billingEmailAddress;	
			_shippingFirstName = shippingFirstName;	
			_shippingLastName = shippingLastName;	
			_shippingAddressLine1 = shippingAddressLine1;	
			_shippingAddressLine2 = shippingAddressLine2;	
			_shippingCity = shippingCity;	
			_shippingAddressState = shippingAddressState;	
			_shippingAddressCountry = shippingAddressCountry;	
			_shippingZipCode = shippingZipCode;	
			_shippingTelephoneNumber = shippingTelephoneNumber;	
			_shippingEmailAddress = shippingEmailAddress;	
			_isActive = isActive;	
			_isDeleted = isDeleted;	
			_createDate = createDate;	
			_userId = userId;	
			_adminComment = adminComment;	
		}
		
		#endregion
		#region TblUserProfile Properties
		
		 /***********************************************************************************************
                                    -- PROPERTIES --        
         Contains all the properties representing the data fields of the current entity.
         ***********************************************************************************************/

        /// <summary>
        /// This is the Primary key value of the UserProfileId, which can't be assigned from the application,
        /// to ensure the data consistancy, by not letting the user to change the PK_tblUserProfile to update the data of an another TblUserProfile instance.
        /// For view or updation purpose, every TblUserProfile will be retrieved thru the proper 'Get' method.
        /// </summary>
		
		public Int32 UserProfileId
		{
			get {return _userProfileId;}	
		}
		
				
		public String FirstName
		{
			get {return _firstName;}
			set {_firstName = value;}
		}

		public String LastName
		{
			get {return _lastName;}
			set {_lastName = value;}
		}

		public DateTime DateOfBirth
		{
			get {return _dateOfBirth;}
			set {_dateOfBirth = value;}
		}

		public String EmailAddress
		{
			get {return _emailAddress;}
			set {_emailAddress = value;}
		}

		public String UserGender
		{
			get {return _userGender;}
			set {_userGender = value;}
		}

		public String UserTelephoneNumber
		{
			get {return _userTelephoneNumber;}
			set {_userTelephoneNumber = value;}
		}

		public String UserFaxNumber
		{
			get {return _userFaxNumber;}
			set {_userFaxNumber = value;}
		}

		public String CompanyName
		{
			get {return _companyName;}
			set {_companyName = value;}
		}

		public String CompanyTelephoneNumber
		{
			get {return _companyTelephoneNumber;}
			set {_companyTelephoneNumber = value;}
		}

		public String CompanyFaxNumber
		{
			get {return _companyFaxNumber;}
			set {_companyFaxNumber = value;}
		}

		public String BillingFirstName
		{
			get {return _billingFirstName;}
			set {_billingFirstName = value;}
		}

		public String BillingLastName
		{
			get {return _billingLastName;}
			set {_billingLastName = value;}
		}

		public String BillingAddressLine1
		{
			get {return _billingAddressLine1;}
			set {_billingAddressLine1 = value;}
		}

		public String BillingAddressLine2
		{
			get {return _billingAddressLine2;}
			set {_billingAddressLine2 = value;}
		}

		public String BillingCity
		{
			get {return _billingCity;}
			set {_billingCity = value;}
		}

		public String BillingAddressState
		{
			get {return _billingAddressState;}
			set {_billingAddressState = value;}
		}

		public String BillingAddressCountry
		{
			get {return _billingAddressCountry;}
			set {_billingAddressCountry = value;}
		}

		public String BillingZipCode
		{
			get {return _billingZipCode;}
			set {_billingZipCode = value;}
		}

		public String BillingTelephoneNumber
		{
			get {return _billingTelephoneNumber;}
			set {_billingTelephoneNumber = value;}
		}

		public String BillingEmailAddress
		{
			get {return _billingEmailAddress;}
			set {_billingEmailAddress = value;}
		}

		public String ShippingFirstName
		{
			get {return _shippingFirstName;}
			set {_shippingFirstName = value;}
		}

		public String ShippingLastName
		{
			get {return _shippingLastName;}
			set {_shippingLastName = value;}
		}

		public String ShippingAddressLine1
		{
			get {return _shippingAddressLine1;}
			set {_shippingAddressLine1 = value;}
		}

		public String ShippingAddressLine2
		{
			get {return _shippingAddressLine2;}
			set {_shippingAddressLine2 = value;}
		}

		public String ShippingCity
		{
			get {return _shippingCity;}
			set {_shippingCity = value;}
		}

		public String ShippingAddressState
		{
			get {return _shippingAddressState;}
			set {_shippingAddressState = value;}
		}

		public String ShippingAddressCountry
		{
			get {return _shippingAddressCountry;}
			set {_shippingAddressCountry = value;}
		}

		public String ShippingZipCode
		{
			get {return _shippingZipCode;}
			set {_shippingZipCode = value;}
		}

		public String ShippingTelephoneNumber
		{
			get {return _shippingTelephoneNumber;}
			set {_shippingTelephoneNumber = value;}
		}

		public String ShippingEmailAddress
		{
			get {return _shippingEmailAddress;}
			set {_shippingEmailAddress = value;}
		}

		public Boolean IsActive
		{
			get {return _isActive;}
			set {_isActive = value;}
		}

		public Boolean IsDeleted
		{
			get {return _isDeleted;}
			set {_isDeleted = value;}
		}

		public DateTime CreateDate
		{
			get {return _createDate;}
			set {_createDate = value;}
		}

		public Int32 UserId
		{
			get {return _userId;}
			set {_userId = value;}
		}

		public String AdminComment
		{
			get {return _adminComment;}
			set {_adminComment = value;}
		}
		

		#endregion
		#region TblUserProfile Static Methods
		/************************************************************************************
                                    -- CREATE METHOD (STATIC) --
        *************************************************************************************/
		/************************* Architecure note:**********************************
        Note 1:
        This method is specially useful for the case, where we need to use Object Data Source controls.
        For ObjectDataSource/SqlDataSource controls, the insert/update metnod requires paramters methods, rather property based methods.
        However, there is still a way to pass property based objects as method parameter for data source controls, 
        but in that case we could not use Sql type, as view controls or asp parameter control can only contain few of primitive type.
        The main reason to remain the Sql Type in our object architecture is it is faster and contains better way for null value support.
        
        Note 2: 
        Non-primary key: it should be primitive type, as the asp paramter control (included in data source control) supports only primitive types.
        /*****************************************************************************/
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
        public static  Int32 CreateNewTblUserProfile
		(
			String firstName,
			String lastName,
			DateTime dateOfBirth,
			String emailAddress,
			String userGender,
			String userTelephoneNumber,
			String userFaxNumber,
			String companyName,
			String companyTelephoneNumber,
			String companyFaxNumber,
			String billingFirstName,
			String billingLastName,
			String billingAddressLine1,
			String billingAddressLine2,
			String billingCity,
			String billingAddressState,
			String billingAddressCountry,
			String billingZipCode,
			String billingTelephoneNumber,
			String billingEmailAddress,
			String shippingFirstName,
			String shippingLastName,
			String shippingAddressLine1,
			String shippingAddressLine2,
			String shippingCity,
			String shippingAddressState,
			String shippingAddressCountry,
			String shippingZipCode,
			String shippingTelephoneNumber,
			String shippingEmailAddress,
			Boolean isActive,
			Boolean isDeleted,
			DateTime createDate,
			Int32 userId,
			String adminComment
		)
		{
			//creating an empty TblUserProfile object
            TblUserProfile tblUserProfile = new TblUserProfile();
				tblUserProfile.FirstName = firstName;
				tblUserProfile.LastName = lastName;
				tblUserProfile.DateOfBirth = dateOfBirth;
				tblUserProfile.EmailAddress = emailAddress;
				tblUserProfile.UserGender = userGender;
				tblUserProfile.UserTelephoneNumber = userTelephoneNumber;
				tblUserProfile.UserFaxNumber = userFaxNumber;
				tblUserProfile.CompanyName = companyName;
				tblUserProfile.CompanyTelephoneNumber = companyTelephoneNumber;
				tblUserProfile.CompanyFaxNumber = companyFaxNumber;
				tblUserProfile.BillingFirstName = billingFirstName;
				tblUserProfile.BillingLastName = billingLastName;
				tblUserProfile.BillingAddressLine1 = billingAddressLine1;
				tblUserProfile.BillingAddressLine2 = billingAddressLine2;
				tblUserProfile.BillingCity = billingCity;
				tblUserProfile.BillingAddressState = billingAddressState;
				tblUserProfile.BillingAddressCountry = billingAddressCountry;
				tblUserProfile.BillingZipCode = billingZipCode;
				tblUserProfile.BillingTelephoneNumber = billingTelephoneNumber;
				tblUserProfile.BillingEmailAddress = billingEmailAddress;
				tblUserProfile.ShippingFirstName = shippingFirstName;
				tblUserProfile.ShippingLastName = shippingLastName;
				tblUserProfile.ShippingAddressLine1 = shippingAddressLine1;
				tblUserProfile.ShippingAddressLine2 = shippingAddressLine2;
				tblUserProfile.ShippingCity = shippingCity;
				tblUserProfile.ShippingAddressState = shippingAddressState;
				tblUserProfile.ShippingAddressCountry = shippingAddressCountry;
				tblUserProfile.ShippingZipCode = shippingZipCode;
				tblUserProfile.ShippingTelephoneNumber = shippingTelephoneNumber;
				tblUserProfile.ShippingEmailAddress = shippingEmailAddress;
				tblUserProfile.IsActive = isActive;
				tblUserProfile.IsDeleted = isDeleted;
				tblUserProfile.CreateDate = createDate;
				tblUserProfile.UserId = userId;
				tblUserProfile.AdminComment = adminComment;
			
			return TblUserProfile.CreateNewTblUserProfile(tblUserProfile);
		}
	
		/************************************************************************************
                 -- UPDATE METHODS (STATIC) --
        *************************************************************************************/

        /************************* Architecure note:**********************************
        Note 1:
        This method is specially useful for the case, where we need to use Object Data Source controls.
        For ObjectDataSource/SqlDataSource controls, the insert/update metnod requires paramters methods, rather property based methods.
        However, there is still a way to pass property based objects as method parameter for data source controls, 
        but in that case we could not use Sql type, as view controls or asp parameter control can only contain few of primitive type.
        The main reason to remain the Sql Type in our object architecture is it is faster and contains better way for null value support.
        
        Note 2: 
        There the two types of paramaters will be passed here.
         * a. Primary key paramater: it should be Sql type, as we will bind the primary key property for the view controls (form view, details view etc) as datakey.
         * b. Non-primary key: it should be primitive type, as the asp paramter control (included in data source control) supports only primitive types.
        /*****************************************************************************/
		
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public static  bool UpdateTblUserProfile
		(
			Int32 userProfileId,
			String firstName,
			String lastName,
			DateTime dateOfBirth,
			String emailAddress,
			String userGender,
			String userTelephoneNumber,
			String userFaxNumber,
			String companyName,
			String companyTelephoneNumber,
			String companyFaxNumber,
			String billingFirstName,
			String billingLastName,
			String billingAddressLine1,
			String billingAddressLine2,
			String billingCity,
			String billingAddressState,
			String billingAddressCountry,
			String billingZipCode,
			String billingTelephoneNumber,
			String billingEmailAddress,
			String shippingFirstName,
			String shippingLastName,
			String shippingAddressLine1,
			String shippingAddressLine2,
			String shippingCity,
			String shippingAddressState,
			String shippingAddressCountry,
			String shippingZipCode,
			String shippingTelephoneNumber,
			String shippingEmailAddress,
			Boolean isActive,
			Boolean isDeleted,
			DateTime createDate,
			Int32 userId,
			String adminComment
		)
		{
			 TblUserProfile tblUserProfile =  TblUserProfile.GetTblUserProfileByUserProfileId(userProfileId);
			
				tblUserProfile.FirstName = firstName;
				tblUserProfile.LastName = lastName;
				tblUserProfile.DateOfBirth = dateOfBirth;
				tblUserProfile.EmailAddress = emailAddress;
				tblUserProfile.UserGender = userGender;
				tblUserProfile.UserTelephoneNumber = userTelephoneNumber;
				tblUserProfile.UserFaxNumber = userFaxNumber;
				tblUserProfile.CompanyName = companyName;
				tblUserProfile.CompanyTelephoneNumber = companyTelephoneNumber;
				tblUserProfile.CompanyFaxNumber = companyFaxNumber;
				tblUserProfile.BillingFirstName = billingFirstName;
				tblUserProfile.BillingLastName = billingLastName;
				tblUserProfile.BillingAddressLine1 = billingAddressLine1;
				tblUserProfile.BillingAddressLine2 = billingAddressLine2;
				tblUserProfile.BillingCity = billingCity;
				tblUserProfile.BillingAddressState = billingAddressState;
				tblUserProfile.BillingAddressCountry = billingAddressCountry;
				tblUserProfile.BillingZipCode = billingZipCode;
				tblUserProfile.BillingTelephoneNumber = billingTelephoneNumber;
				tblUserProfile.BillingEmailAddress = billingEmailAddress;
				tblUserProfile.ShippingFirstName = shippingFirstName;
				tblUserProfile.ShippingLastName = shippingLastName;
				tblUserProfile.ShippingAddressLine1 = shippingAddressLine1;
				tblUserProfile.ShippingAddressLine2 = shippingAddressLine2;
				tblUserProfile.ShippingCity = shippingCity;
				tblUserProfile.ShippingAddressState = shippingAddressState;
				tblUserProfile.ShippingAddressCountry = shippingAddressCountry;
				tblUserProfile.ShippingZipCode = shippingZipCode;
				tblUserProfile.ShippingTelephoneNumber = shippingTelephoneNumber;
				tblUserProfile.ShippingEmailAddress = shippingEmailAddress;
				tblUserProfile.IsActive = isActive;
				tblUserProfile.IsDeleted = isDeleted;
				tblUserProfile.CreateDate = createDate;
				tblUserProfile.UserId = userId;
				tblUserProfile.AdminComment = adminComment;
			
			return TblUserProfile.UpdateTblUserProfile(tblUserProfile);
		}

		/************************************************************************************
                         -- DELETE METHODS --
        *************************************************************************************/
        /************************* Architecure note:**********************************
        We have used the employeeId parameter as SqlInt32, to bind the delete method with object data source and view control directly.
        ****************************************************************************/
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public static  bool DeleteTblUserProfile
		(
			Int32 userProfileId
		)
		{
			//Validate Input
			if(userProfileId <= GetUserProfileIdMinValue)
				throw (new ArgumentOutOfRangeException("userProfileId"));
				
			// Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
			AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
			AddParameterToSqlCmd(sqlCmd, "@UserProfileId",SqlDbType.Int, 0, ParameterDirection.Input, userProfileId);
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLUSERPROFILE_DELETETBLUSERPROFILE);
			ExecuteScalarCmd(sqlCmd);
			int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
			return (returnValue == 0 ? false : true);
			
		}
		
		/// <summary>
        /// Deletes a set of employees from the database.
        /// </summary>
		public static bool DeleteTblUserProfileList( System.Collections.Generic.List<Int32>  userProfileIdListToDelete)
		{
			//Validate Input
			foreach (Int32 userProfileId in userProfileIdListToDelete)
			    if(userProfileId <= GetUserProfileIdMinValue)
					throw (new ArgumentOutOfRangeException("userProfileId"));
			
			//performing deletion operation //

            string xmlString = FormatXMLForIdArray(userProfileIdListToDelete);
			
			// Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
			AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            AddParameterToSqlCmd(sqlCmd, "@UserProfileIdList", SqlDbType.Xml, xmlString.ToString().Length, ParameterDirection.Input, xmlString.ToString());
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLUSERPROFILE_DELETETBLUSERPROFILELIST);
			ExecuteScalarCmd(sqlCmd);
			int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
			return (returnValue == userProfileIdListToDelete.Count ? true : false);
		}
		
		/************************************************************************************
                                 -- GET BY PRIMARY METHODS --
        *************************************************************************************/
        /************************* Architecure note:**********************************
        Retrives an Employee from database, based on it's primary key.
        To view or update an employee, everytime we must have to use this type of 'get' method, 
        since we don't have direct access to the Primary key value for assigning value.
        We have used the employeeId parameter as SqlInt32, to bind the delete method with object data source and view control directly.
        /*****************************************************************************/
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
		public static TblUserProfile GetTblUserProfileByUserProfileId(Int32 userProfileId)
		{
			if(userProfileId <= GetUserProfileIdMinValue)
					throw (new ArgumentOutOfRangeException("userProfileId"));
				
		 	// Execute SQL Command
			SqlCommand sqlCmd = new SqlCommand();
			AddParameterToSqlCmd(sqlCmd, "@UserProfileId",SqlDbType.Int, 0, ParameterDirection.Input, userProfileId);
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLUSERPROFILE_GETTBLUSERPROFILEBYUSERPROFILEID);
			GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblUserProfileCollectionFromReader);
            CustomCollection<TblUserProfile> objCollection = ((CustomCollection<TblUserProfile>)ExecuteReaderCmd(sqlCmd, test));

            if (objCollection.Count > 0)
                return objCollection[0];
            else
                return null;
		}
		
		/************************************************************************************
                         -- GET BY FOREIGN KEY METHODS --
        *************************************************************************************/
				
				
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, false)]
		public static CustomCollection<TblUserProfile> GetTblUserProfileByUserId(Int32 userId)
		{
			if(userId <= GetUserIdMinValue)
					throw (new ArgumentOutOfRangeException("userId"));
				
		 	// Execute SQL Command
			SqlCommand sqlCmd = new SqlCommand();
			AddParameterToSqlCmd(sqlCmd, "@UserId",SqlDbType.Int, 0, ParameterDirection.Input, userId);
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLUSERPROFILE_GETTBLUSERPROFILEBYUSERID);
			GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblUserProfileCollectionFromReader);
            CustomCollection<TblUserProfile> objCollection = ((CustomCollection<TblUserProfile>)ExecuteReaderCmd(sqlCmd, test));

            if (objCollection.Count > 0)
                return objCollection;
            else
                return null;
		}
		
		/// <summary>
        /// Gets all the TblUserProfile regarding 'PREFERRED_LANGUAGE_ID' foreign key.
        /// It supports efficient paging.
        /// </summary>
        /// <returns>A collection of TblUserProfile.</returns>
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, false)]
        public static CustomCollection<TblUserProfile> GetTblUserProfileByUserIdPaged(Int32 userId,String orderBy, Int32 startRowIndex, Int32 maximumRows)
		{
            //Validate Input
			if(userId <= GetUserIdMinValue)
					throw (new ArgumentOutOfRangeException("userId"));
			
            if (orderBy == "")
                orderBy = "UserId";

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
			AddParameterToSqlCmd(sqlCmd, "@UserId",SqlDbType.Int, 0, ParameterDirection.Input, userId);
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRowIndex);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, maximumRows);

            SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLUSERPROFILE_GETTBLUSERPROFILEBYUSERIDPAGED);

            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblUserProfileCollectionFromReader);
            CustomCollection<TblUserProfile> objCollection = ((CustomCollection<TblUserProfile>)ExecuteReaderCmd(sqlCmd, test));

            return objCollection;
        }
		
		/// <summary>
        /// This is a supporting method of 'GetEmployeeByPREFERRED_LANGUAGE_IDPagedPagedCountPaged' method.
        /// Used in paging, which returns the total number of records, returned from the ''GetEmployeeByReportsToPaged'' method (regardless of page size).
        /// Although we are not using the parameters, but we need the same signature as ''GetEmployeeByReportsToPaged'' to support paging.
        /// </summary>
		public static int GetTblUserProfileByUserIdPagedCount(Int32 userId,String orderBy, Int32 startRowIndex, Int32 maximumRows)
        {
            //Validate Input
			if(userId <= GetUserIdMinValue)
					throw (new ArgumentOutOfRangeException("userId"));
			
			// Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
			AddParameterToSqlCmd(sqlCmd, "@UserId",SqlDbType.Int, 0, ParameterDirection.Input, userId);
			AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLUSERPROFILE_GETTBLUSERPROFILEBYUSERIDPAGEDCOUNT);
            ExecuteScalarCmd(sqlCmd);

            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }
		
		/************************************************************************************
                 -- GET ALL METHODS --
        *************************************************************************************/
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static CustomCollection<TblUserProfile> GetAllTblUserProfile()
		{
		
		 	// Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLUSERPROFILE_GETALLTBLUSERPROFILE);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblUserProfileCollectionFromReader);
            CustomCollection<TblUserProfile> objCollection = ((CustomCollection<TblUserProfile>)ExecuteReaderCmd(sqlCmd, test));

            return objCollection;
		}
		
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static CustomCollection<TblUserProfile> GetAllTblUserProfilePaged(String orderBy, Int32 startRowIndex, Int32 maximumRows)
        {
            //Validate Input
            if (orderBy == "")
                orderBy = "UserProfileId";

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRowIndex);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, maximumRows);

            SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLUSERPROFILE_GETALLTBLUSERPROFILEPAGED);

            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblUserProfileCollectionFromReader);
            CustomCollection<TblUserProfile> objCollection = ((CustomCollection<TblUserProfile>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;
        }
		
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static int GetAllTblUserProfilePagedCount(String orderBy, Int32 startRowIndex, Int32 maximumRows)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();

            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLUSERPROFILE_GETALLTBLUSERPROFILEPAGEDCOUNT);
            ExecuteScalarCmd(sqlCmd);

            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }
		
		#endregion
		#region Employee Instance Methods
		/************************************************************************************
                                    -- SAVE (INSERT/UPDATE) METHODS (INSTANCE) --
        *************************************************************************************/
		/// <summary>
        /// Saves (inserts and updates) an Employee into database.
        /// The insertion occur if the EmployeeId conatins default value.
        /// Otherwises it updates the Employee into the database, based on the primary key value stored in EmployeeId.
        /// This technique ensures an Employee will not be updated without having a valid EmployeeId.
        /// </summary>
		public bool Save()
		{
			if(UserProfileId<= GetUserProfileIdMinValue)
			{
				Int32 TempId=CreateNewTblUserProfile(this);
				if(TempId>0)
				{
					_userProfileId=TempId;
					return true;
				}
				else
				{
					// error occurs
					return false;
				}
			}
			else
			{	//This is a update Command
				return (UpdateTblUserProfile(this));
			}
			
		}
		
		public static Int32 CreateNewTblUserProfile(TblUserProfile newTblUserProfile)
		{
			// validate Parameters
			if (newTblUserProfile == null)
				throw (new ArgumentNullException("newTblUserProfile"));

			// Execute SQL Command
			SqlCommand sqlCmd = new SqlCommand();
			int length = 0;
			AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            
			AddParameterToSqlCmd(sqlCmd, "@FirstName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.FirstName);
			AddParameterToSqlCmd(sqlCmd, "@LastName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.LastName);
			AddParameterToSqlCmd(sqlCmd, "@DateOfBirth",SqlDbType.DateTime, 0, ParameterDirection.Input, newTblUserProfile.DateOfBirth);
			AddParameterToSqlCmd(sqlCmd, "@EmailAddress",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.EmailAddress);
			AddParameterToSqlCmd(sqlCmd, "@UserGender",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.UserGender);
			AddParameterToSqlCmd(sqlCmd, "@UserTelephoneNumber",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.UserTelephoneNumber);
			AddParameterToSqlCmd(sqlCmd, "@UserFaxNumber",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.UserFaxNumber);
			AddParameterToSqlCmd(sqlCmd, "@CompanyName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.CompanyName);
			AddParameterToSqlCmd(sqlCmd, "@CompanyTelephoneNumber",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.CompanyTelephoneNumber);
			AddParameterToSqlCmd(sqlCmd, "@CompanyFaxNumber",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.CompanyFaxNumber);
			AddParameterToSqlCmd(sqlCmd, "@BillingFirstName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.BillingFirstName);
			AddParameterToSqlCmd(sqlCmd, "@BillingLastName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.BillingLastName);
			AddParameterToSqlCmd(sqlCmd, "@BillingAddressLine1",SqlDbType.NVarChar, 4000, ParameterDirection.Input, newTblUserProfile.BillingAddressLine1);
			AddParameterToSqlCmd(sqlCmd, "@BillingAddressLine2",SqlDbType.NVarChar, 4000, ParameterDirection.Input, newTblUserProfile.BillingAddressLine2);
			AddParameterToSqlCmd(sqlCmd, "@BillingCity",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.BillingCity);
			AddParameterToSqlCmd(sqlCmd, "@BillingAddressState",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.BillingAddressState);
			AddParameterToSqlCmd(sqlCmd, "@BillingAddressCountry",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.BillingAddressCountry);
			AddParameterToSqlCmd(sqlCmd, "@BillingZipCode",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.BillingZipCode);
			AddParameterToSqlCmd(sqlCmd, "@BillingTelephoneNumber",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.BillingTelephoneNumber);
			AddParameterToSqlCmd(sqlCmd, "@BillingEmailAddress",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.BillingEmailAddress);
			AddParameterToSqlCmd(sqlCmd, "@ShippingFirstName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.ShippingFirstName);
			AddParameterToSqlCmd(sqlCmd, "@ShippingLastName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.ShippingLastName);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressLine1",SqlDbType.NVarChar, 4000, ParameterDirection.Input, newTblUserProfile.ShippingAddressLine1);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressLine2",SqlDbType.NVarChar, 4000, ParameterDirection.Input, newTblUserProfile.ShippingAddressLine2);
			AddParameterToSqlCmd(sqlCmd, "@ShippingCity",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.ShippingCity);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressState",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.ShippingAddressState);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressCountry",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.ShippingAddressCountry);
			AddParameterToSqlCmd(sqlCmd, "@ShippingZipCode",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.ShippingZipCode);
			AddParameterToSqlCmd(sqlCmd, "@ShippingTelephoneNumber",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.ShippingTelephoneNumber);
			AddParameterToSqlCmd(sqlCmd, "@ShippingEmailAddress",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.ShippingEmailAddress);
			AddParameterToSqlCmd(sqlCmd, "@IsActive",SqlDbType.Bit, 0, ParameterDirection.Input, newTblUserProfile.IsActive);
			AddParameterToSqlCmd(sqlCmd, "@IsDeleted",SqlDbType.Bit, 0, ParameterDirection.Input, newTblUserProfile.IsDeleted);
			AddParameterToSqlCmd(sqlCmd, "@CreateDate",SqlDbType.DateTime, 0, ParameterDirection.Input, newTblUserProfile.CreateDate);
			AddParameterToSqlCmd(sqlCmd, "@UserId",SqlDbType.Int, 0, ParameterDirection.Input, newTblUserProfile.UserId);
			AddParameterToSqlCmd(sqlCmd, "@AdminComment",SqlDbType.NVarChar, -1, ParameterDirection.Input, newTblUserProfile.AdminComment);
			
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLUSERPROFILE_CREATENEWTBLUSERPROFILE);
			ExecuteScalarCmd(sqlCmd);
			return (Int32.Parse(sqlCmd.Parameters["@ReturnValue"].Value.ToString()));

		}
		/// <summary>
        /// Updates an TblUserProfile instance to the database.
        /// </summary>
		public static bool UpdateTblUserProfile(TblUserProfile newTblUserProfile)
		{
			// validate Parameters
			if (newTblUserProfile == null)
				throw (new ArgumentNullException("newTblUserProfile"));

			// Execute SQL Command
			SqlCommand sqlCmd = new SqlCommand();
			int length = 0;
			AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            
			AddParameterToSqlCmd(sqlCmd, "@UserProfileId",SqlDbType.Int, 0, ParameterDirection.Input, newTblUserProfile.UserProfileId);
			AddParameterToSqlCmd(sqlCmd, "@FirstName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.FirstName);
			AddParameterToSqlCmd(sqlCmd, "@LastName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.LastName);
			AddParameterToSqlCmd(sqlCmd, "@DateOfBirth",SqlDbType.DateTime, 0, ParameterDirection.Input, newTblUserProfile.DateOfBirth);
			AddParameterToSqlCmd(sqlCmd, "@EmailAddress",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.EmailAddress);
			AddParameterToSqlCmd(sqlCmd, "@UserGender",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.UserGender);
			AddParameterToSqlCmd(sqlCmd, "@UserTelephoneNumber",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.UserTelephoneNumber);
			AddParameterToSqlCmd(sqlCmd, "@UserFaxNumber",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.UserFaxNumber);
			AddParameterToSqlCmd(sqlCmd, "@CompanyName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.CompanyName);
			AddParameterToSqlCmd(sqlCmd, "@CompanyTelephoneNumber",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.CompanyTelephoneNumber);
			AddParameterToSqlCmd(sqlCmd, "@CompanyFaxNumber",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.CompanyFaxNumber);
			AddParameterToSqlCmd(sqlCmd, "@BillingFirstName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.BillingFirstName);
			AddParameterToSqlCmd(sqlCmd, "@BillingLastName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.BillingLastName);
			AddParameterToSqlCmd(sqlCmd, "@BillingAddressLine1",SqlDbType.NVarChar, 4000, ParameterDirection.Input, newTblUserProfile.BillingAddressLine1);
			AddParameterToSqlCmd(sqlCmd, "@BillingAddressLine2",SqlDbType.NVarChar, 4000, ParameterDirection.Input, newTblUserProfile.BillingAddressLine2);
			AddParameterToSqlCmd(sqlCmd, "@BillingCity",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.BillingCity);
			AddParameterToSqlCmd(sqlCmd, "@BillingAddressState",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.BillingAddressState);
			AddParameterToSqlCmd(sqlCmd, "@BillingAddressCountry",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.BillingAddressCountry);
			AddParameterToSqlCmd(sqlCmd, "@BillingZipCode",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.BillingZipCode);
			AddParameterToSqlCmd(sqlCmd, "@BillingTelephoneNumber",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.BillingTelephoneNumber);
			AddParameterToSqlCmd(sqlCmd, "@BillingEmailAddress",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.BillingEmailAddress);
			AddParameterToSqlCmd(sqlCmd, "@ShippingFirstName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.ShippingFirstName);
			AddParameterToSqlCmd(sqlCmd, "@ShippingLastName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.ShippingLastName);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressLine1",SqlDbType.NVarChar, 4000, ParameterDirection.Input, newTblUserProfile.ShippingAddressLine1);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressLine2",SqlDbType.NVarChar, 4000, ParameterDirection.Input, newTblUserProfile.ShippingAddressLine2);
			AddParameterToSqlCmd(sqlCmd, "@ShippingCity",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.ShippingCity);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressState",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.ShippingAddressState);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressCountry",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.ShippingAddressCountry);
			AddParameterToSqlCmd(sqlCmd, "@ShippingZipCode",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.ShippingZipCode);
			AddParameterToSqlCmd(sqlCmd, "@ShippingTelephoneNumber",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblUserProfile.ShippingTelephoneNumber);
			AddParameterToSqlCmd(sqlCmd, "@ShippingEmailAddress",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblUserProfile.ShippingEmailAddress);
			AddParameterToSqlCmd(sqlCmd, "@IsActive",SqlDbType.Bit, 0, ParameterDirection.Input, newTblUserProfile.IsActive);
			AddParameterToSqlCmd(sqlCmd, "@IsDeleted",SqlDbType.Bit, 0, ParameterDirection.Input, newTblUserProfile.IsDeleted);
			AddParameterToSqlCmd(sqlCmd, "@CreateDate",SqlDbType.DateTime, 0, ParameterDirection.Input, newTblUserProfile.CreateDate);
			AddParameterToSqlCmd(sqlCmd, "@UserId",SqlDbType.Int, 0, ParameterDirection.Input, newTblUserProfile.UserId);
			AddParameterToSqlCmd(sqlCmd, "@AdminComment",SqlDbType.NVarChar, -1, ParameterDirection.Input, newTblUserProfile.AdminComment);
			
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLUSERPROFILE_UPDATETBLUSERPROFILE);
            ExecuteScalarCmd(sqlCmd);
			int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
			return (returnValue == 0 ? false : true);
		}
		#endregion
		
		#region TblUserProfile Related Collections
		/// <summary>
        /// Creates and returns a strongly typed collection of Employee custom entity. 
        /// The colelction is created through iterating on the IdataReader object which contains Employee information, as a set of records, similar to tabular format.
        /// </summary>
		public static CollectionBase  GenerateTblUserProfileCollectionFromReader(IDataReader returnData) 
		{
			
			//creating the instance of Employee collection
			CustomCollection<TblUserProfile> colTblUserProfile = new CustomCollection<TblUserProfile>();
			
			/************************* Architecure note:**********************************
             * Below code includes the null value functionality to retieve the data which has nill value in database end.
             * Design consideration:
             * Besides general data fields, special care should be taken for primary keys, to assign '0'/defaultvalue, rather passing 'Null' value in constructor parameter.
             * Although we are considering sqldb tyoe data for the current data container, but while retireving data from database end, through datareader object, we need to cast data reader objects using .net primitive data type, 
             * rather using sqldb type to cast, since data reader objects don't support sql db type to be casted.
             *****************************************************************************/

            //Iterating thriugh the data reader, to generate Employee collection.

			//getting the Employee collection by iterating thru the data reader
			while (returnData.Read()) 
			{
				//passing the TblUserProfile constructor parameters from the current instance of data reader fields.
				TblUserProfile newTblUserProfile = new TblUserProfile
				(
					returnData["UserProfileId"]== System.DBNull.Value ? GetUserProfileIdMinValue : (Int32 ) returnData["UserProfileId"],
					returnData["FirstName"]== System.DBNull.Value ? string.Empty: (String ) returnData["FirstName"],
					returnData["LastName"]== System.DBNull.Value ? string.Empty: (String ) returnData["LastName"],
					returnData["DateOfBirth"]== System.DBNull.Value ? DateTime.MinValue: (DateTime ) returnData["DateOfBirth"],
					returnData["EmailAddress"]== System.DBNull.Value ? string.Empty: (String ) returnData["EmailAddress"],
					returnData["UserGender"]== System.DBNull.Value ? string.Empty: (String ) returnData["UserGender"],
					returnData["UserTelephoneNumber"]== System.DBNull.Value ? string.Empty: (String ) returnData["UserTelephoneNumber"],
					returnData["UserFaxNumber"]== System.DBNull.Value ? string.Empty: (String ) returnData["UserFaxNumber"],
					returnData["CompanyName"]== System.DBNull.Value ? string.Empty: (String ) returnData["CompanyName"],
					returnData["CompanyTelephoneNumber"]== System.DBNull.Value ? string.Empty: (String ) returnData["CompanyTelephoneNumber"],
					returnData["CompanyFaxNumber"]== System.DBNull.Value ? string.Empty: (String ) returnData["CompanyFaxNumber"],
					returnData["BillingFirstName"]== System.DBNull.Value ? string.Empty: (String ) returnData["BillingFirstName"],
					returnData["BillingLastName"]== System.DBNull.Value ? string.Empty: (String ) returnData["BillingLastName"],
					returnData["BillingAddressLine1"]== System.DBNull.Value ? string.Empty: (String ) returnData["BillingAddressLine1"],
					returnData["BillingAddressLine2"]== System.DBNull.Value ? string.Empty: (String ) returnData["BillingAddressLine2"],
					returnData["BillingCity"]== System.DBNull.Value ? string.Empty: (String ) returnData["BillingCity"],
					returnData["BillingAddressState"]== System.DBNull.Value ? string.Empty: (String ) returnData["BillingAddressState"],
					returnData["BillingAddressCountry"]== System.DBNull.Value ? string.Empty: (String ) returnData["BillingAddressCountry"],
					returnData["BillingZipCode"]== System.DBNull.Value ? string.Empty: (String ) returnData["BillingZipCode"],
					returnData["BillingTelephoneNumber"]== System.DBNull.Value ? string.Empty: (String ) returnData["BillingTelephoneNumber"],
					returnData["BillingEmailAddress"]== System.DBNull.Value ? string.Empty: (String ) returnData["BillingEmailAddress"],
					returnData["ShippingFirstName"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingFirstName"],
					returnData["ShippingLastName"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingLastName"],
					returnData["ShippingAddressLine1"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingAddressLine1"],
					returnData["ShippingAddressLine2"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingAddressLine2"],
					returnData["ShippingCity"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingCity"],
					returnData["ShippingAddressState"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingAddressState"],
					returnData["ShippingAddressCountry"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingAddressCountry"],
					returnData["ShippingZipCode"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingZipCode"],
					returnData["ShippingTelephoneNumber"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingTelephoneNumber"],
					returnData["ShippingEmailAddress"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingEmailAddress"],
					returnData["IsActive"]== System.DBNull.Value ? false: (Boolean ) returnData["IsActive"],
					returnData["IsDeleted"]== System.DBNull.Value ? false: (Boolean ) returnData["IsDeleted"],
					returnData["CreateDate"]== System.DBNull.Value ? DateTime.MinValue: (DateTime ) returnData["CreateDate"],
					returnData["UserId"]== System.DBNull.Value ? 0: (Int32 ) returnData["UserId"],
					returnData["AdminComment"]== System.DBNull.Value ? string.Empty: (String ) returnData["AdminComment"]

				);
				//adding the Employee to the collection
				colTblUserProfile.Add(newTblUserProfile);
			}
			
			//returns the collection of Companys 
			return (colTblUserProfile);
		}
		
		#endregion
		#region Constants and Default Values
		
		public static Int32 GetUserProfileIdMinValue
		{
			get
			{
				return 0;
			}
		}
		public static Int32 GetUserIdMinValue
		{
			get
			{
				return 0;
			}
		}
		
		//create method related contants
			internal const string SPR_TBLUSERPROFILE_CREATENEWTBLUSERPROFILE="spr_TblUserProfile_CreateNewTblUserProfile";
			internal const string SPR_TBLUSERPROFILE_UPDATETBLUSERPROFILE="spr_TblUserProfile_UpdateTblUserProfile";
			internal const string SPR_TBLUSERPROFILE_DELETETBLUSERPROFILE="spr_TblUserProfile_DeleteTblUserProfile";
			internal const string SPR_TBLUSERPROFILE_DELETETBLUSERPROFILELIST="spr_TblUserProfile_DeleteTblUserProfileList";
			internal const string SPR_TBLUSERPROFILE_GETTBLUSERPROFILEBYUSERPROFILEID="spr_TblUserProfile_GetTblUserProfileByUserProfileId";
			internal const string SPR_TBLUSERPROFILE_GETTBLUSERPROFILEBYUSERID="spr_TblUserProfile_GetTblUserProfileByUserId";
			internal const string SPR_TBLUSERPROFILE_GETTBLUSERPROFILEBYUSERIDPAGED="spr_TblUserProfile_GetTblUserProfileByUserIdPaged";
			internal const string SPR_TBLUSERPROFILE_GETTBLUSERPROFILEBYUSERIDPAGEDCOUNT="spr_TblUserProfile_GetTblUserProfileByUserIdPagedCount";
			internal const string SPR_TBLUSERPROFILE_GETALLTBLUSERPROFILE="spr_TblUserProfile_GetAllTblUserProfile";
			internal const string SPR_TBLUSERPROFILE_GETALLTBLUSERPROFILEPAGED="spr_TblUserProfile_GetAllTblUserProfilePaged";
			internal const string SPR_TBLUSERPROFILE_GETALLTBLUSERPROFILEPAGEDCOUNT="spr_TblUserProfile_GetAllTblUserProfilePagedCount";
		
		#endregion
	}
}	
